﻿@using NOSDC.Services.Extensions
@model NOSDC.Models.EventsViewModel
@section Title{ @Html.CreatePageTitle("Events") }

@{
    var options = new AjaxOptions
    {
        UpdateTargetId = "pastEvents",
        InsertionMode = InsertionMode.Replace
    };       
}
    @if (Model.NoEvent)
    {
    <div class="newsPosting">
        <div>
            <div class="leftIcon">
            </div>
            <div class="titleWrapper">
                <div class="newsTitle">
                    No upcoming events
                </div>
            </div>
        </div>
        <div class="rightIcon">
        </div>
    </div>

        <div style="height: 100px; vertical-align: middle; text-align: center; line-height: 100px;">
             There are currently no events scheduled. Please check back soon!
         </div>
    }
    else
    {
        <div class="newsPosting">
            <div>
                <div class="leftIcon">
                </div>
                <div class="titleWrapper">
                    <div class="newsTitle">
                        Upcoming events
                    </div>
                </div>
            </div>
            <div class="rightIcon">
            </div>
        </div>
        
        <div id="upcomingEvents">
            @if (Model.UpcomingEvents.Any())
            {
                <div id="newEvents">
                    @foreach (var item in Model.UpcomingEvents)
                    {
                        <div class="eventList">
                            <div class="eventTitle">@if(!String.IsNullOrWhiteSpace(item.Logo)){<img style="vertical-align:middle;" src="@Url.Content("~/Images/Logos/" + @item.Logo)" alt="" />} <span style="vertical-align: middle;">@Html.ActionLink(item.Title, "Index", "Events", new { item.EventID, Title = item.Title.ToSeoUrl() }, null)</span></div>
                            <div class="eventDate">
                                <span class="eventField">Date</span>: @item.StartDate.ToString("MMMM  d, yyyy hh:mm")</div>
                            <div class="eventLocation">
                                <span class="eventField">Location</span>: @item.Location</div>
                            <div class="eventDescription">
                                <span class="eventField">About the event</span><br />
                                @item.Description.StripHTML().Truncate(500)
                            </div>
                            <div style="text-align: center;">@Html.ActionLink("View full event details", "Index", "Events", new { item.EventID, Title = item.Title.ToSeoUrl() }, null)</div>
                        </div>
                    }
                </div>
            }
        </div>
    }<br/>
<div class="newsPosting">
    <div>
        <div class="leftIcon">
        </div>
        <div class="titleWrapper">
            <div class="newsTitle">
                Previous NOSDC events
            </div>
        </div>
    </div>
    <div class="rightIcon">
    </div>
</div>

    <div id="pastEvents">
        @if (Model.PastEvents.Any())
        {
            @Html.Hidden("currentCount", @Model.PastEvents.Count(), new { id = "currentCount" })
            @Html.Hidden("totalCount", @Model.TotalEvents, new { id = "totalCount" })
                <input id="currentPage" type="hidden" value="1" />
                <div id="events">
                    @foreach (var item in Model.PastEvents)
                    {
                        <div class="eventList">
                            <div class="eventTitle"><img style="vertical-align:middle;" src="@Url.Content("~/Images/Logos/" + @item.Logo)" alt="" /> <span style="vertical-align: middle;">@Html.ActionLink(item.Title, "Index", "Events", new { item.EventID, Title = item.Title.ToSeoUrl() }, null)</span></div>
                            <div class="eventDate">
                                <span class="eventField">Date</span>: @item.StartDate.ToString("MMMM  d, yyyy hh:mm")</div>
                            <div class="eventLocation">
                                <span class="eventField">Location</span>: @item.Location</div>
                            <div class="eventDescription">
                                <span class="eventField">About the event</span><br />
                                @item.Description.StripHTML().Truncate(500)
                            </div>
                            <div style="text-align: center;">@Html.ActionLink("View full event details", "Index", "Events", new { item.EventID, Title = item.Title.ToSeoUrl() }, null)</div>
                        </div>
                    }
                </div>
                    if (Model.TotalEvents > 3)
                    {
                <div class="buttons" style="margin: auto; padding: 0; padding-top: 10px; text-align: center; float: none;">
                    <button id="getMore" type="button" class="regular" style="float: none; display: inline">
                        <img src="@Url.Content("~/Images/eventButton.png")" alt="" /> Get More Events</button>
                </div>
                    }
        }
    </div>

<br />
@section MetaTags{
}
@section Right
{
    @{Html.RenderAction("RecentJobs", "Jobs");}
    <br />
    <div class="newsPosting">
        <div>
            <div class="leftIcon">
            </div>
            <div class="upcomingEvents">
                <div class="newsTitle">
                    Search Events
                </div>
            </div>
        </div>
        <div class="rightIcon">
        </div>
    </div>
    <div id="eventCalendar" style="padding-top: 10px;">
    </div>
    <br />
    <div style="text-align: center;">@Html.ActionLink("View all past events.", "All", "Events")</div>
    <br />
}
@section JavaScript{
    <script src="@Url.Content("~/Scripts/jquery-ui.min.js")" type="text/javascript"></script>
    <script src="../../Scripts/eventsPaging.js" type="text/javascript"></script>
    <script src="../../Scripts/UpcomingEvents.js" type="text/javascript"></script>
    <script type="text/javascript">
        $("#Events").addClass("selected");
        $("#eventCalendar").datepicker();
        $("#signUp").click(function () {
            eventSignup(Model.EventId);
        });
    </script>
}
@section CSS{
    <link href="../../Content/themes/redmond/jquery-ui-1.8.16.custom.css" rel="stylesheet" type="text/css" />
}
